package com.linkin.homepage

import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.WindowManager
import com.linkin.homepage.app.PreloadApi
import com.linkin.homepage.base.BaseActivity
import com.linkin.homepage.ui.home.MainFragment

class MainActivity : BaseActivity() {

    private val mLastTime: Long = 0
    private var mMainFragment: MainFragment? = null

    override fun getLayoutResource(): Int {
        return R.layout.activity_main
    }

    override fun beforeLoading() {
        // 设置主题样式
        // 设置主题样式
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.decorView.systemUiVisibility =
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            window.statusBarColor = Color.TRANSPARENT
        } else {
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        }
    }

    override fun initView() {
        mMainFragment = MainFragment.newInstance("3")
        getSupportFragmentManager().beginTransaction()
            .add(R.id.main_fragment_container, mMainFragment!!)
            .commit();
    }

    override fun initData() {
        super.initData()
        PreloadApi.initData(this)
    }

    override fun clear() {
    }
}